package com.yuandian.business.monitor.controller;

import com.yuandian.api.business_monitor.po.AlarmParams;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.business.monitor.service.IBusiAdvancedAlarmService;
import com.yuandian.utils.PageDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 高级告警表 前端控制器
 * </p>
 *
 * @author fucx
 * @since 2020-11-10
 */
@Slf4j
@RestController
@RequestMapping("/alarm/advanced")
@Api(tags = "自定义告警接口")
public class BusiAdvancedAlarmController {

	@Autowired
	private IBusiAdvancedAlarmService busiAdvancedAlarmService;

	/**
	 * 查询自定义告警数据
	 * @param params 参数
	 * @return 通用返回对象
	 */
	@ApiOperation(value = "自定义告警数据", notes = "自定义告警数据")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId",  			value = "系统id",  			paramType = "query", required = true,  dataType = "Integer"),
			@ApiImplicitParam(name = "alarmLevelIds",  		value = "告警等级列表",  		paramType = "query", required = false, dataType = "List<Integer>"),
			@ApiImplicitParam(name = "objectTypeIds", 		value = "告警对象列表",  		paramType = "query", required = false, dataType = "List<Integer>"),
			@ApiImplicitParam(name = "segmentIds", 			value = "网端ID列表",  		paramType = "query", required = false, dataType = "List<Integer>"),
			@ApiImplicitParam(name = "pageNum",   			value = "页码", 				paramType = "query", required = true,  dataType = "Long"),
			@ApiImplicitParam(name = "pageSize", 			value = "每页大小", 			paramType = "query", required = true,  dataType = "Long"),
			@ApiImplicitParam(name = "startTime", 			value = "开始时间", 			paramType = "query", required = true,  dataType = "String"),
			@ApiImplicitParam(name = "endTime",   			value = "结束时间", 			paramType = "query", required = true,  dataType = "String")
	})
	@PostMapping("/getAdvancedAlarm")
	public R<PageDataInfo> getAdvancedAlarm(@ApiIgnore @RequestBody AlarmParams params) {
		PageDataInfo data = busiAdvancedAlarmService.getAdvancedAlarm(params);
		return R.ok(data);
	}

	/**
	 * 查询自定义告警数据-下载
	 * @param params 参数
	 * @return 通用返回对象
	 */
	@ApiOperation(value = "自定义告警数据-下载", notes = "自定义告警数据-下载")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId",  			value = "系统id",  			paramType = "query", required = true,  dataType = "Integer"),
			@ApiImplicitParam(name = "alarmLevelIds",  		value = "告警等级列表",  		paramType = "query", required = false, dataType = "List<Integer>"),
			@ApiImplicitParam(name = "objectTypeIds", 		value = "告警对象列表",  		paramType = "query", required = false, dataType = "List<Integer>"),
			@ApiImplicitParam(name = "segmentIds", 			value = "网端ID列表",  		paramType = "query", required = false, dataType = "List<Integer>"),
			@ApiImplicitParam(name = "startTime", 			value = "开始时间", 			paramType = "query", required = true,  dataType = "String"),
			@ApiImplicitParam(name = "endTime",   			value = "结束时间", 			paramType = "query", required = true,  dataType = "String")
	})
	@PostMapping("/exportExcel")
	public void exportExcel(@RequestBody AlarmParams params,HttpServletResponse response) {
		busiAdvancedAlarmService.exportExcel(params,response);
	}

}
